package com.sike.javacore.serializer.protobuf;


import sun.plugin2.main.client.ProcessUI;

import java.util.ArrayList;

public class ProtoBufTest02 {
    public static void main(String[] args) {
        StudentDTO studentDTO = new StudentDTO();
        studentDTO.setId(1);
        studentDTO.setName("张三");
        studentDTO.setSex("1");
        studentDTO.setHobbybes(new ArrayList<String>(){{add("足球");add("篮球");}});

        byte[] datas = ProtoBufUtil.serialize(studentDTO);
        System.out.println("序列化内容");
        for(byte b : datas){
            System.out.print(b);
        }

        System.out.println();
        System.out.println("==============================");
        System.out.println("反序列化内容");

        StudentDTO studentDTO1 = ProtoBufUtil.deserialize(datas,StudentDTO.class);
        System.out.println("id：" + studentDTO1.getId());
        System.out.println("sex：" + studentDTO1.getSex());
        System.out.println("name：" + studentDTO1.getName());
        System.out.println("hobbybes：" + studentDTO1.getHobbybes().toString());
    }
}
